/*
 * 依赖库，依赖c++11
 */
#include <iostream>

#include "contacts.pb.h"

int main()
{
    std::string people_str;

    //序列化
    contacts::PeopleInfo people;
    people.set_name("yumoz");
    people.set_age(100);
    if(!people.SerializeToString(&people_str))
    {
        std::cerr << "error" << std::endl;
        return -1;
    }

    //反序列化
    contacts::PeopleInfo people;
    if(!people.ParseFromString(people_str))
    {
        std::cerr << "fan error" << std::endl;
        return -1;
    }

    // 打印输出
    std::cout << "fan success " << std::endl
        << "name: " << people.name() << std::endl
        << "age:" << people.age() << std::endl;

    return 0; 
}